<template>
  <basePage :page-params="pageParams">
    <view style="padding: 0 20rpx;">
      <MenuCell
        :cell-data.sync="menuList"
        :cell-column="cellColumn"
        @handelCellMethod="handelCellMethod"
      />
      <MenuCell
        :cell-data.sync="extraInfo.data"
        :cell-column="extraInfo.cells"
        @handelCellMethod="handelCellMethod"
      />
      <MenuCell
        :cell-column="agreementCellColumn"
        @handelCellMethod="handelCellMethod"
      />
      <view class="btn-box">
        <button class="btn confirm-btn btn-noborder" :plain="true" @click.stop="$u.throttle(quitEvent, 500)">退出登录</button>
      </view>
    </view>
  </basePage>
</template>

<script>
import basePage from '@/components/base-page'
import MenuCell from '@/components/menu-cell'
export default {
  name: 'Index',
  components: {
    basePage,
    MenuCell
  },
  data() {
    return {
      pageParams: {
        state: null,
        emptyTitle: '',
        errorTitle: '',
        showButton: false
      },
      cellColumn: [
        {
          label: '手机号',
          fields: ['phoneNum'],
          contentStyle: 'font-size: 24rpx;color: #808080;padding-right: 32rpx;'
        },
        {
          label: '个人资料',
          showRightIcon: true,
          linkUrl: '/myAccount/personalData/index',
        }
      ],
      extraInfo: {
        data: {},
        cells: [],
        defaultCells: [
          {
            label: '收货地址',
            showRightIcon: true,
            linkUrl: '/address/addressList',
          },
          {
            label: '发票抬头',
            showRightIcon: true,
            linkUrl: '/invoiceManage/invoiceList',
          }
        ]
      },
      agreementCellColumn: [
        {
          label: '《鑫方盛服务协议》',
          showRightIcon: true,
          linkUrl: '/login/login/agree',
        },
        {
          label: '《隐私政策》',
          showRightIcon: true,
          linkUrl: '/login/login/pol',
        },
      ],
      menuList: {
        phoneNum: ''
      }
    }
  },
  mounted() {
    this.initPageFn()
  },
  methods: {
    initPageFn() {
      const {
        mobilePhone
      } = this.vuex_memberInfo
      this.menuList.phoneNum = mobilePhone
      // 设置个人中心的列表
      if (!this.vuex_loginStatus || (this.vuex_loginStatus && this.vuex_memberInfo && (this.vuex_memberInfo.accountType == 20 || this.vuex_memberInfo.accountType == 30))) {
        this.cellColumn = [
          {
            label: '手机号',
            fields: ['phoneNum'],
            contentStyle: 'font-size: 24rpx;color: #808080;padding-right: 32rpx;'
          },
          {
            label: '个人资料',
            showRightIcon: true,
            linkUrl: '/myAccount/personalData/index',
          }
        ]
        this.extraInfo.cells = [...this.extraInfo.defaultCells]
      } else {
        this.cellColumn = [
          {
            label: '手机号',
            fields: ['phoneNum'],
            contentStyle: 'font-size: 24rpx;color: #808080;padding-right: 32rpx;'
          },
          {
            label: '个人资料',
            showRightIcon: true,
            linkUrl: '/myAccount/personalData/index',
          }
        ]
        this.extraInfo.cells = []
      }
    },
    quitEvent() {
      this.$u.vuex('vuex_allMemberInfos', {})
      this.$u.vuex('vuex_userInfo', {})
      this.$u.vuex('vuex_accountInfo', {})
      this.$u.vuex('vuex_loginStatus', false)
      this.$u.vuex('vuex_token', '')
      this.$u.vuex('vuex_memberInfo', {})
      this.$u.vuex('vuex_crmCustomerInfos', [])
      this.$u.vuex('vuex_memberCompanyInfo', {})
      this.$u.vuex('vuex_memberLevelResp', {})
      this.$u.vuex('vuex_cityInfo', {})
      this.$u.vuex('vuex_login_code', '')
      // #ifdef H5
      this.$cookie.remove('memberId')
      this.$cookie.remove('loginAccount')
      this.$cookie.remove('accountType')
      this.$cookie.remove('platformName')
      this.$cookie.remove('sourceUrl')
      this.$cookie.remove('lgdomain');
      this.$cookie.remove('registerSource');
      // #endif
      uni.$u.vuex('vuex_first_enter_home', true)
      uni.removeStorageSync('inviteCode');
      uni.redirectTo({
        url: `/pages/myAccount/index`
      })
    },
  }
}
</script>

<style lang="scss" scoped>
.btn-box{
  position: absolute;
  left: 64rpx;
  bottom: 68rpx;
  .confirm-btn{
    width: 624rpx;
    height: 64rpx;
    line-height: 64rpx;
    color: $uni-bg-color;
    background: linear-gradient(128.8deg, rgba(255,121,95,1) 0%, rgba(238,61,26,1) 100%);
    font-size: $uni-font-size-base;
  }
}
</style>
